Variance and Generalized Constraints for C# Generics
نویسندگان
چکیده
Generic types in C behave invariantly with respect to subtyping. We propose a system of type-safe variance for C that supports the declaration of covariant and contravariant type parameters on generic types. To support more widespread application of variance we also generalize the existing constraint mechanism with arbitrary subtype assertions on classes and methods. This extension is useful even in the absence of variance, and subsumes equational constraints proposed for Generalized Algebraic Data Types (GADTs). We formalize the subtype relation in both declarative and syntax-directed style, and describe and prove the correctness of algorithms for constraint closure and subtyping. Finally, we formalize and prove a type safety theorem for a featherweight language with variant classes and generalized constraints.
منابع مشابه
An extended comparative study of language support for generic programming
Many modern programming languages support basic generics, sufficient to implement type-safe polymorphic containers. Some languages have moved beyond this basic support, and in doing so have enabled a broader, more powerful form of generic programming. This paper reports on a comprehensive comparison of facilities for generic programming in eight programming languages: C++, Standard ML, Objectiv...
متن کاملDuality for vector equilibrium problems with constraints
In the paper, we study duality for vector equilibrium problems using a concept of generalized convexity in dealing with the quasi-relative interior. Then, their applications to optimality conditions for quasi-relative efficient solutions are obtained. Our results are extensions of several existing ones in the literature when the ordering cones in both the objective space and the constr...
متن کاملSubtyping in Java with Generics and Wildcards is a Fractal
While developing their software, professional object-oriented (OO) software developers keep in their minds an image of the subtyping relation between types in their software. The goal of this paper is to present an observation about the graph of the subtyping relation in Java, namely the observation that, after the addition of generics—and of wildcards, in particular—to Java, the graph of the s...
متن کاملAn Extended Empirical Likelihood for Generalized Linear Models
The paper considers improving the efficiency of parameter estimation of the quasi-likelihood in generalized linear models. The improvement is offered by employing the empirical likelihood and incorporating extra constraints which better utilize the provided variance structure of the models. We recommend a particular choice for the extra constraints to reduce the variance of the quasi-likelihood...
متن کاملA Language for Generic Programming in the Large
Generic programming is an effective methodology for developing reusable software libraries. Many programming languages provide generics and have features for describing interfaces, but none completely support the idioms used in generic programming. To address this need we developed the language G. The central feature of G is the concept, a mechanism for organizing constraints on generics that i...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2006